import requests

import config
class CourseAPI:
    def __init__(self):
        self.url_insert_course = config.BASE_URL + "/api/clues/course"
        self.url_select_course = config.BASE_URL + "/api/clues/course/list"
        self.url_update_course = config.BASE_URL + "/api/clues/course"
        self.url_delete_course = config.BASE_URL +"/api/clues/course/{}"
    #增加课程
    def insert_course(self,token,insert_course_json):
        return requests.post(url=self.url_insert_course,headers={"Authorization":token},json=insert_course_json)
    #查询课程
    def select_course(self,token):
        return requests.get(url=self.url_select_course,headers={"Authorization":token})
    # 更新课程
    def upate_course(self,token,update_course_json):
        return requests.put(url=self.url_update_course,headers={"Authorization":token},json=update_course_json)
    # 删除课程
    def delete_course(self,id,token):
        return requests.delete(url=self.url_delete_course.format(id),headers={"Authorization":token})
